using System;
using System.Collections.Generic;
using System.Text;
using GameFramework;
using GameEngine;

namespace Projet_X0
{
    public class Player : Character
    {
        public Player(Vector2D position, float direction, int characterID, float health, Weapons weapons)
            : base(position, direction, characterID, new InputControl(), health, weapons)
        {
            control.SetSource(this);
            weapons.AddWeapon(new Weapon(100f, 5, 10f, 10, 100));
            weapons.AddWeapon(new Weapon(200f, 7, 20f, 10, 500));
            speed.Set(4);
        }

        public class InputControl : Action
        {
            public InputControl(Player source)
                : base(source)
            {

            }

            public InputControl()
                : base()
            {
            }

            public override void Run()
            {
                Player player = (Player)source;
                IInput input = GameManager.GetServices().input;

                player.rotateRight.Activate(input.IsKeyPressed(Keys.Right));
                player.rotateLeft.Activate(input.IsKeyPressed(Keys.Left));
                player.moveFront.Activate(input.IsKeyPressed(Keys.Up));
                player.fire.Activate(input.IsKeyPressed(Keys.Space));
                if (input.IsKeyPressed(Keys.Tab))
                {
                    player.weapons.NextWeapon();
                }
            }
        }
    }
}
